import request from '@/utils/request';

export function fetchList(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/user/page',
		method: 'get',
		params: query,
	});
}

export function addObj(obj: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/user',
		method: 'post',
		data: obj,
	});
}

export function getObj(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/user/' + id,
		method: 'get',
	});
}

export function delObj(id: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/user/' + id,
		method: 'delete',
	});
}

export function putObj(obj: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/user',
		method: 'put',
		data: obj,
	});
}

export function getDetails(obj: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/user/details/' + obj,
		method: 'get',
	});
}

// 更改个人信息
export function editInfo(obj: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/user/edit',
		method: 'put',
		data: obj,
	});
}

// 获取用户信息模板
export function fetchUserTemplate(name: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/sys-file/local/file/' + name,
		method: 'get',
		responseType: 'blob',
	});
}
